using OneCaps.Core.Interfaces;

namespace OneCaps.Infrastructure.Hardware
{
    /// <summary>
    /// 支付终端服务模拟实现
    /// </summary>
    public class MockPaymentTerminalService : IPaymentTerminalService
    {
        private readonly Dictionary<string, PaymentStatusResult> _payments = new();

        public Task<PaymentResult> PayAsync(string terminalId, decimal amount, string orderId)
        {
            var result = new PaymentResult
            {
                Success = true,
                TransactionId = Guid.NewGuid().ToString(),
                Message = "支付成功"
            };
            _payments[orderId] = new PaymentStatusResult
            {
                Paid = true,
                TransactionId = result.TransactionId,
                Message = "已支付"
            };
            return Task.FromResult(result);
        }

        public Task<PaymentStatusResult> GetPaymentStatusAsync(string orderId)
        {
            if (_payments.TryGetValue(orderId, out var status))
                return Task.FromResult(status);
            return Task.FromResult(new PaymentStatusResult
            {
                Paid = false,
                TransactionId = null,
                Message = "未支付"
            });
        }
    }
} 